FolderTreeWindow = Ext.extend(Ext.Window, {
	src : '',
	title : '',
	selected : null,
	constructor : function(conf) {
		this.src = conf.src;
		this.title = conf.title;
		var treePanel = new Ext.tree.TreePanel({
			// rootVisible:false, //隐藏根节点
			id : 'tree',
			region : 'center',
			split : true,
			border : true, // 边框
			animate : true, // 动画效果
			autoScroll : true, // 自动滚动
			enableDD : false, // 拖拽节点
			containerScroll : true,
			lines : true,
			loader : new Ext.tree.TreeLoader({
				dataUrl : 'getDirectories'
			}),
			root : new Ext.tree.AsyncTreeNode({
				id : '\\',
				// iconCls : 'db-icn-world',
				text : '全部文件'
			})
		});

		FolderTreeWindow.superclass.constructor.call(this, {
			height : 300,
			width : 500,
			frame : true,
			title : this.title,
			id : 'win',
			items : treePanel,
			buttonAlign : 'center',
			buttons : [ {
				text : '确定',
				id : 'ok',
				handler : function() {
					var win = Ext.getCmp('win');
					win.doAction();
					win.close();
				}
			}, {
				text : '取消',
				id : 'cancle',
				handler : function() {
					Ext.getCmp('win').close();
				}
			} ]
		});
		// Ext.apply(this, conf);

		treePanel.on('click', function(node) {
			Ext.getCmp('win').selected = node.id;
			console.log("selected=" + node.id);
		});
	},
	/**
	 * 新建文件夹
	 */
	/*newFolder : function() {
		//Ext.MessageBox.alert("提示", "新建文件夹");

		console.log("currentFolder:"+this.currentFolder);
		var thisCur=this.currentFolder;
		Ext.MessageBox.prompt("新建文件夹","输入文件夹名称",function(btn,text){
			if(btn=='ok'){
				//ajax配置开始
				var ajaxConf = {
						url : 'createFolder',
						params : {
							"target" : thisCur+"\\"+text
						},
						success : function(resp, opts) {
							// 刷新数据
							var respObj = Ext.util.JSON
									.decode(resp.responseText);
							if (respObj.success) {
							//	Ext.MessageBox.alert("提示", respObj.msg);
								Ext.getCmp("gridPanel").getStore()
										.reload();
							} else {
								Ext.MessageBox.alert("提示", "创建失败");
							}
						},
						failur : function(resp, opts) {
							Ext.MessageBox.alert("提示", "创建失败");
						}
					};
				//ajax配置结束
				console.log("新建文件夹："+thisCur+"\\"+text);
				Ext.Ajax.request(ajaxConf);
			}
		});
		
	},*/
	/**
	 * 单击确定按钮的响应处理函数
	 */
	doAction : function() {
		if (this.title === '复制到') {
			console.log("把 " + this.src + " 复制到 " + this.selected);
			//提交请求
			Ext.Ajax.request({
				url : 'copy',
				params : {
					"srcName":this.src,
					"target":this.selected
				},
				success : function(resp, opts) {
					//刷新数据
					var usedspace=$("#use_space").html().split('.');
					var respObj=Ext.util.JSON.decode(resp.responseText);
					if(respObj.success){
						usedspace=respObj.usedspace;
			        	$("#use_space").html((usedspace/1024/1024).toFixed(2)+"M")
			        	$(".spaceUI_span").width(155*(usedspace/1024/1024).toFixed(2)/totalsize);
			        	Ext.getCmp("gridPanel").getStore().reload();
						Ext.MessageBox.alert("提示",respObj.msg);
						}else{
							Ext.MessageBox.alert("提示",respObj.msg);
						}
				},
				failur:function(resp, opts){
					var respObj=Ext.util.JSON.decode(resp.responseText);
					Ext.MessageBox.alert("提示",respObj.msg);
				}
			});
		} else if (this.title === '移动到') {
			console.log("把 " + this.src + " 移动到 " + this.selected);
			//提交请求
			Ext.Ajax.request({
				url : 'move',
				params : {
					"srcName":this.src,
					"target":this.selected
				},
				success : function(resp, opts) {
					var respObj=Ext.util.JSON.decode(resp.responseText);
					if(respObj.success){
						Ext.getCmp("gridPanel").getStore().reload();
						Ext.MessageBox.alert("提示",respObj.msg);
						}else{
							Ext.MessageBox.alert("提示",respObj.msg);
						}
						
				},
				failur:function(resp, opts){
					//var respObj=Ext.util.JSON.decode(resp.responseText);
					Ext.MessageBox.alert("提示","操作失败，请重试！");
				}
			});
		}
	}

});